//Page Object
import {request} from '../../request/index.js'
Page({
  data: {
    swiperList:[],
    navList:[],
    floorList:[]
  },
  //options(Object)
  onLoad: function(options) {
    /* var reqTask = wx.request({
      url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
      data: {},
      header: {'content-type':'application/json'},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (result) => {
        this.setData({
          swiperList:result.data.message
        })
      },
      fail: () => {},
      complete: () => {}
    }); */
    this.getSwiper(),
    this.getNav(),
    this.getFloor()
  },
  getSwiper(){//banner
    request({
      url: '/home/swiperdata'
    }).then(res=>{
      console.log(res);
      res.forEach(v => {
        v.navigator_url = v.navigator_url.replace("main", "index")
      });
      this.setData({
        swiperList: res
      })
    })
  },
  getNav() {//nav
    request({
      url: '/home/catitems'
    }).then(res => {
      this.setData({
        navList: res
      })
    })
  },
  getFloor() {//floor
    request({
      url: '/home/floordata'
    }).then(res => {
      /* res.forEach(v => {
        v.navigator_url = v.navigator_url.replace("t", "t/index")
      }); */
      this.setData({
        floorList: res
      })
    })
  },
  onReady: function() {
    
  },
  onShow: function() {
    
  },
  onHide: function() {

  },
  onUnload: function() {

  },
  onPullDownRefresh: function() {

  },
  onReachBottom: function() {

  },
  onShareAppMessage: function() {

  },
  onPageScroll: function() {

  },
  //item(index,pagePath,text)
  onTabItemTap:function(item) {

  }
});
  